#include <iostream>
#include <algorithm>
#include <cstdio>
#include <array>
#include <vector>
using namespace std;
#ifdef ONLINE_JUDGE

#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 23], *p1 = buf, *p2 = buf, ubuf[1 << 23], *u = ubuf;

#endif
int read() {
	int p = 0, flg = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') flg = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		p = p * 10 + c - '0';
		c = getchar();
	}
	return p * flg;
}
void write(int x) {
	if (x < 0) {
		x = -x;
		putchar('-');
	}
	if (x > 9) {
		write(x / 10);
	}
	putchar(x % 10 + '0');
}
bool _stmer;

const int N = 51, mod = 1e9 + 7;

/*

unordered_map <bitset <41>, int> idx;

array <array <>, 2>, N> f;

char strbuf[N];
string s;

void prod(bitset <41> &tp, int x, int y) {
	tp[x * 4] = y & 1, tp[x * 4 + 1] = (y >> 1) & 1;
	tp[x * 4 + 2] = (y >> 2) & 1, tp[x * 4 + 3] = (y >> 3) & 1;
}

int redu(bitset <41> &tp, int x) {
	int res = tp[x * 4];
	res += tp[x * 4 + 1] << 1;
	res += tp[x * 4 + 2] << 2;
	res += tp[x * 4 + 3] << 3;
	return res;
}

int cnt;

void dfs1(int x, int n, int sum, bitset <41> isl) {
	if (idx[isl]) return;
	if (x >= 9) {
		cnt++;
		prod(isl, x, n - sum);
		idx[isl] = cnt;
		return;
	}
	for (int i = 0; i <= n - sum; i++) {
		prod(isl, x, i);
		dfs1(x + 1, n, sum + i, isl);
	}
}

void dfs(int x, int n, bool flg1, bool flg2, bitset <41> isl) {
	int ed = '9';
	if (flg1) ed = s[x];
	for (int i = '0'; i <= )
}

*/

void Mod(int &x) {
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void solve() {
	int n = read();
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int tp = i;
		vector <int> isl(10, 0);
		while (tp) isl[tp % 10]++, tp /= 10;
		int ans1 = 0, ans2 = 0;
		for (int j = 0; j <= 9; j++)
			if (ans1 <= isl[j]) ans1 = isl[j], ans2 = j;
		ans += ans2, Mod(ans);
	}
	write(ans), puts("");
}

bool _edmer;
int main() {
	cerr << (&_stmer - &_edmer) / 1024.0 / 1024.0 << "MB\n";
#ifndef cxqghzj
	freopen("give.in", "r", stdin);
	freopen("give.out", "w", stdout);
#endif
	int T = read();
	while (T--) solve();
	return 0;
}
